package es.ucm.fdi.xtremeaudio.modelo.utils;

import java.io.File;

/**
 * The open directory class
 * 
 * @author elena
 *
 */
public class OpenDirectory {
	
	/**
	 * The directory path
	 */
	private String _DIRECTORYPATH;
	/**
	 * list of xml files
	 */
	private String[] _FILES;
	/**
	 * the extension of the files we want to be included on the list
	 */
	private String _EXTENSION;
	/**
	 * the file filter
	 */
	private FileFilter _FILTER;
	
	/**
	 * Constructor
	 * 
	 * @param directory The directory
	 */
	public OpenDirectory(String path, String ext){
		_DIRECTORYPATH = path;
		_EXTENSION = ext;
		File directory = new File(_DIRECTORYPATH);
		_FILTER = new FileFilter(directory, _EXTENSION);
		_FILES = directory.list(_FILTER);
	}
	
	/**
	 * Get the directory path
	 * 
	 * @return the directory path
	 */
	public String get_DIRECTORYPATH() {
		return _DIRECTORYPATH;
	}

	/**
	 * Set the directory path
	 * 
	 * @param _DIRECTORYPATH the new directory path
	 */
	public void set_DIRECTORYPATH(String _DIRECTORYPATH) {
		this._DIRECTORYPATH = _DIRECTORYPATH;
	}

	/**
	 * Get the list of xml files
	 * 
	 * @return the list of xml files
	 */
	public String[] get_FILES() {
		return _FILES;
	}
	
	/**
	 * Get file in the position i of the list
	 * 
	 * @param i the position of the file
	 * @return the file
	 */
	public String getFile(int i){
		return _FILES[i];
	}

}
